<template>
    <div>
        <h3>客户维护</h3>
        <el-table
                :data="tableData.slice((currentPage-1)*PageSize,currentPage*PageSize)" style="width: 100%">
                :data="tableData"
                stripe
                style="width: 100%">
            <el-table-column
                    prop="code"
                    label="客户编号">
            </el-table-column>
            <el-table-column
                    prop="realname"
                    label="真实姓名">
            </el-table-column>
            <el-table-column
                    prop="username"
                    label="客户名">
            </el-table-column>
            <el-table-column
                    prop="sex"
                    label="性别">
            </el-table-column>
            <el-table-column
                    prop="phone"
                    label="电话">
            </el-table-column>
            <el-table-column
                    prop="image"
                    label="资质图片">
            </el-table-column>
            <el-table-column
                    prop="sfzimg"
                    label="身份证图片">
            </el-table-column>
            <el-table-column
                    prop="companyname"
                    label="客户公司名称">
            </el-table-column>
            <el-table-column
                    prop="state"
                    label="状态">
            </el-table-column>
            <el-table-column
                    prop="grade"
                    label="等级">
            </el-table-column>

            <el-table-column
                    fixed="right"
                    label="操作">
                <template slot-scope="scope">
                    <el-button :disabled="scope.row.state=='冻结'? true:false" @click="choice(scope.row.customerid)" type="text" size="small">冻结</el-button>
                    <el-button @click="findOrder(scope.row.customerid)" type="text" size="small">消费情况</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="tabListPage">
            <el-pagination @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="currentPage"
                           :page-sizes="pageSizes"
                           :page-size="PageSize" layout="total, sizes, prev, pager, next, jumper"
                           :total="totalCount">
            </el-pagination>
        </div>

        <el-dialog
                title="订单列表"
                :visible.sync="dialogVisible"
                width="50%">
            <el-table
                    :data="orderTableData"
                    stripe
                    style="width: 100%">
                <el-table-column
                        prop="code"
                        label="订单编号">
                </el-table-column>
                <el-table-column
                        prop="orderstate"
                        label="订单状态">
                </el-table-column>
                <el-table-column
                        prop="address"
                        label="收货地址">
                </el-table-column>
                <el-table-column
                        prop="time"
                        label="下单时间">
                </el-table-column>
                <el-table-column
                        prop="type"
                        label="订单类型">
                </el-table-column>
                <el-table-column
                        prop="money"
                        label="订单金额">
                </el-table-column>

            </el-table>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "CustomerView",
        data(){
            return {
                tableData: [],
                input:{
                    userName:''
                },
                dialogVisible:false,
                orderTableData:[],
                totalCount:null,
                currentPage:1,
                pageSizes:[1,2,3,4,5],
                PageSize:3,
            }
        },
        mounted() {
            this.init()
        },
        methods:{
            handleSizeChange(val) {
                this.PageSize=val
                this.currentPage=1
            },
            handleCurrentChange(val) {
                this.currentPage=val
            },
            init(){
                this.$axios.get("/sscsys/customer/findAll").then(
                    r=>{
                        console.log(r.data)
                        this.tableData=r.data
                        this.totalCount=r.data.length;
                    }
                )
            },
            choice(id){
                this.$axios.get("/sscsys/customer/findById/"+id).then(
                    r=>{
                        console.log(r.data)
                        this.$message.success("正在审核")
                    }
                )
            },
            findOrder(id){
                this.dialogVisible=true
                this.$axios.get("/sscsys/customer/findOrderById/"+id).then(
                    r=>{
                        console.log(r.data)
                        this.orderTableData=r.data
                    }
                )
            }
        }
    }
</script>

<style scoped>

</style>